package com.chengjue.utils;

import com.chengjue.model.RequireModel;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.util.EntityUtils;

import java.util.List;

public class URLFecter {
	public static List<RequireModel> parseMovie(HttpClient client, String url) throws Exception{
		// 获取网站响应的html，这里调用了HTTPUtils类
		HttpResponse response = HTTPUtils.getRawHtml(client, url);
		// 获取响应状态码
		int StatusCode = response.getStatusLine().getStatusCode();
		if (StatusCode == 200) {
			String entity = EntityUtils.toString(response.getEntity(), "utf-8");
			return MoviePrase.getData(entity);
		} else {
			// 否则，消耗掉实体
			EntityUtils.consume(response.getEntity());
			return null;
		}
	}

}
